;(function($){
    //楼层标签
var floor = $("#floatTool");
//每一层
var a = $(".ceil");
//楼层主要内容
var channel = $(".channel");


// var colorObj = {0:"#ff7b30",
//                 1:"#1bb145",
//                 2:"#2289ff",
//                 3:"#010101",
//                 4:"#ff2f91"            
// }


$(window).scroll(function(){
    //获取到页面总高度
    // var HeightAll = $("html,body").height();
    //获取滚动条位置
    var iTop = $(window).scrollTop();
    // console.log(iTop)
    //到指定位置出现
    var position = $(".body-top").offset().top;
    // console.log(position);
    for(var i=0;i<channel.length;i++){
        //楼层的显示和隐藏
        if(iTop >= position){           
            floor.fadeIn();
        }else{
            floor.fadeOut();
        };
        //楼层联动
        var num = 0;
        for(var i=0;i<channel.length;i++){
            if(iTop >= channel[i].offsetTop){
                num = i;
            }
            a[i].children.className = "";
        };
        a[num].children.className = "active";
        for(var i=0;i<a.length;i++){
            a[i].onclick = function(){
                for(var j=0;j<a.length;j++){
                    if(this == a[j]){
                        $("html,body").animate({scrollTop:channel[j].offsetTop},500);
                        // console.log(j);
                        
                    }
                }
            }
        }
    }
})
 


//设置鼠标移入时样式

var colorOBj = {0:"#ff7b30", 1:"#1bb145",2:"#2289ff",3:"#010101",4:" #ff2f91"};
var ceilOnEle = $("#floatTool").find(".on");
$.each(ceilOnEle, function (index, obj) {
    // console.log(index, obj);
    $(obj).children().mouseover(function () {
        $(obj).children().css("background-color", colorOBj[index]).css("color","#fff");
        $(obj).children().parent().siblings(".on").children().css("background-color","");
    })
    $(obj).children().mouseout(function () {
        $(obj).children().parent().siblings(".on").children().css("color","#999999");
    })
    



})


//回到顶部
$(".returntop").click(function(){
    $('html , body').animate({scrollTop: 0},'slow');
})



})(jQuery)

